package scala.collection.immutable

/**
 * set 不可变
 */
object SetTest {
  def main(args: Array[String]): Unit = {
    //集合定义
    val s1 = Set(1, 2, 3, 4, 5)
    println(s1)
    println("--------------")
    //遍历集合
    s1.foreach(println)
    println("--------------")
    //    （2）数据不可重复
    val set1 = Set(1, 2, 3, 1, 2, 3)
    println(set1)

    //    （3）遍历集合
    for (x <- s1) {
      println(x)
    }

    val set2 = set1 + 4
    println(set2)

    val set3 = set2 - 4 + 6
    println(set3)

    val set4 = set2 ++ set3
    println(set4)
  }
}
